import { ipcMain } from 'electron';
import Voucher from '../models/Voucher';
export default class VoucherService {
  constructor() {
    this._registerListing();
  }
  _registerListing = () => {
    console.log('register VoucherService');

    //获取topSort
    ipcMain.on('voucher-gettopsort', (event, arg) => {
      console.log('voucher-gettopsort');
      Voucher.getTopSort(arg).then(value => {
        event.sender.send('voucher-gettopsort-replay', value);
      });
    });

    ipcMain.on('voucher-insert', (event, arg) => {
      console.log('voucher-insert');
      Voucher.insert(arg).then(value => {
        event.sender.send('voucher-insert-replay', value);
      });
    });
  };
}
